{{extend 'pledger_base.html'}}
<script type="text/javascript">
	refreshing_widgets = Array();
	jQuery(document).ready(function(){
	//Our scripts for this page will go here...
	//The buttons that need an overlay...
	$(".overlay_button")
		.live("click", function(){
			overlay = $(this).data("overlay");
			console.log(overlay);
			$("#"+overlay).toggle();
			return false;
		});
	//The x on the top left of the overlays to close the overlay...
	$('.overlay .close')
		.live("click", function(){
			$(this).parent().hide();
		});
	var widgets = Array();

	{{for widget in views:}}
	widgets.push("{{=widget}}");
	{{pass}}
  // alert(widgets);

	function refresher()
	{
		for (i in refreshing_widgets){
			$("#"+refreshing_widgets[i]).load("/{{=request.application}}/refresh/" + refreshing_widgets[i] + "/");
			}
    // alert(refreshing_widgets);
		refreshing_widgets = Array();
	}
	setInterval(refresher,5000);
	$(".producer_message")
		.live("click", function(){
			var location = "{{=URL('read_message')}}/" + $(this).data('id');
			$(this).load(location);
			return false;
		});
	$(".pledge_message")
		.live("click", function(){
			var location = "{{=URL('read_pledge')}}/" + $(this).data('id');
			$(this).load(location);
			return false;
		});
	});
</script>
<script type="text/javascript">
// clear flash div on load
jQuery(".flash").html("").slideDown().delay(1000).slideUp();
</script>

{{for overlay in overlays:}}
<div id="{{=overlay}}" class="overlay">
	<a href="#" title="Close" class="close">X</a>
	{{=LOAD('refresh', overlay, ajax=True)}}
</div>
{{pass}}
<div class="toolbar">
	<a class="button" href='{{="/"+request.application+"/"}}'">
		Home
	</a>

	<a class="button" href='../index/pitch'">
		Pitch Screen
	</a>

  <a class="button" href='../index/on_air'"> 
		Producer Screen
	</a> 

  <a class="button" href='../index/pledge_entry'"> 
		Pledge Entry
	</a> 

	<a class="button help" href="{{=response.helpurl}}" target="_blank">
		Help
	</a>
</div>
<!-- div class="toolbar">
{{for overlay in overlays:}}
	<a class="overlay_button" data-overlay="{{=overlay}}">{{=overlay}}</a>
{{pass}}
</div -->


<div class="row">

{{if not session.organization:}}
	{{redirect(URL(r=request, c='default'))}}
{{elif not session.pledgedrive:}}
	{{redirect(URL(r=request, c='default'))}}
{{elif not session.segment:}}
	{{redirect(URL(r=request, c='default'))}}
{{else:}}


{{if request.args(0) == 'pitch':}}

<div class="row">
{{for widget in views:}}
	<div id="{{=widget}}" class="widget shadow" style="min-width:400px;">
		{{=LOAD('refresh', widget, ajax=True)}}
	</div>
{{pass}}



{{else:}}

<div class="widget shadow" id="organization" style="font-size: 1.5em;">
<h3>{{=session.organization['name']}}</h3>
<span style="color: red">{{=session.organization['phone']}} <br />
{{=session.organization['phone_long_distance']}}</span> <br />
or on the web at <span style="color: blue">{{=session.organization['url']}}</span>
</div>

<div id="create_producer_message" class="widget shadow">
	{{=LOAD('refresh', 'create_producer_message', ajax=True)}}
</div>

<div class="widget shadow">
<iframe src="{{=URL('refresh', 'segment_navigation')}}" width="100%">
</iframe>
</div>

{{pass}}

{{pass}}


{{if request.args(0) == 'pitch':}}

<div class="widget shadow" id="segment_navigation">
<iframe src="{{=URL('refresh', 'segment_navigation')}}" width="100%">
</iframe>
</div>

<script type="text/javascript">
<!--
var x= document.getElementById("segment_navigation");
x.style.width="400px";
// x.style.position="absolute";
// x.style.bottom="0";

//-->
</script>

</div>

{{else:}}

<br clear="all"/>

<div class="row">
{{for widget in views:}}
	<div id="{{=widget}}" class="widget shadow">
		{{=LOAD('refresh', widget, ajax=True)}}
	</div>
{{pass}}
</div>


{{pass}}

